// 对请求进行封装
import Axios from '@/utils/request.js'
export const login = (mobile, code) => {
  return Axios({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    data: {
      mobile: mobile,
      code: code
    }
  })
}
/**
 * 关注用户
 * @param {*} userId 用户的id
 */
export const followUser = userID => {
  return Axios({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target: userID
    }
  })
}
/**
 * 取消关注用户
 * @param {*} userId 用户的id
 */
export const unFollowUser = userID => {
  return Axios({
    method: 'DELETE',
    url: '/app/v1_0/user/followings/' + userID
  })
}
/**
 * 获取用户自已的信息
 */
export const getInfo = () => {
  return Axios({
    method: 'GET',
    url: '/app/v1_0/user'
  })
}
/**
 * 获取用户的个人信息(包括：姓名，性别，生日......)
 */
export const getProfile = () => {
  return Axios({
    method: 'GET',
    url: '/app/v1_0/user/profile'
  })
}
/**
 * 修改个人的三项基本信息
 * @param {*} obj 要修改的内容
 * obj {
 *  name: 姓名,
 *  gender: 性别：男(0) ,女(1)
 *  birthday: 2010-12-20
 * }
 */
export const updateUserInfo = (obj) => {
  return Axios({
    amethod: 'PATCH',
    url: '/app/v1_0/user/profile',
    data: obj
  })
}
/**
 * 修改用户头像
 *
 * obj： 以formData格式保存参数
 */
export const upDatePhoto = obj => {
  return Axios({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data: obj
  })
}
